<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/commons/global.jsp" %>
<script type="text/javascript">
    var appCarouselFigureDataGrid;
    $(function() {
        appCarouselFigureDataGrid = $('#appCarouselFigureDataGrid').datagrid({
            url : '${path }/appCarouselFigure/dataGrid',
            striped : true,
            rownumbers : true,
            pagination : true,
            singleSelect : true,
            idField : 'id',
            sortName : 'id',
            sortOrder : 'asc',
            pageSize : 20,
            pageList : [ 10, 20, 30, 40, 50, 100, 200, 300, 400, 500 ],
            frozenColumns : [ [   {
                width : '100',
                title : '类型',
                field : 'type',
                sortable : true
            }, {
                width : '60',
                title : '编号',
                field : 'index',
                sortable : true
            },
                {
                width : '100',
                title : '名称',
                field : 'name',
                sortable : true
            } ,  {
                width : '80',
                title : '状态',
                field : 'status',
                sortable : true,
                formatter : function(value, row, index) {
                    switch (value) {
                    case 0:
                        return '启用';
                    case 1:
                        return '禁用';
                    }
                }
            } ,  {
                    width : '250',
                    title : '图片',
                    field : 'title_img',
                    sortable : true,
                    formatter : function(value) {
                        var str = '';
                        str += '<img src="'+value+'"  />';
                        return str;
                    }
                },{
                field : 'action',
                title : '操作',
                width : 100,
                formatter : function(value, row, index) {
                    var str = '';
                        <shiro:hasPermission name="/appCarouselFigure/edit">
                            str += '&nbsp;&nbsp;&nbsp;&nbsp;';
                            str += $.formatString('<a href="javascript:void(0)" class="appCarouselFigure-easyui-linkbutton-edit" data-options="plain:true,iconCls:\'fi-pencil icon-blue\'" onclick="editAppCarouselFigureFun(\'{0}\');" >编辑</a>', row.id);
                        </shiro:hasPermission>
                    return str;
                }
            } ] ],
            onLoadSuccess:function(data){
                $('.appCarouselFigure-easyui-linkbutton-edit').linkbutton({text:'编辑'});
            },

        });
    });


    function editAppCarouselFigureFun(id) {
        if (id == undefined) {
            var rows = appCarouselFigureDataGrid.datagrid('getSelections');
            id = rows[0].id;
        } else {
            appCarouselFigureDataGrid.datagrid('unselectAll').datagrid('uncheckAll');
        }
        parent.$.modalDialog({
            title : '编辑',
            width : 500,
            height : 300,
            href : '${path }/appCarouselFigure/editPage?id=' + id,
            buttons : [ {
                text : '确定',
                handler : function() {
                    parent.$.modalDialog.openner_dataGrid = appCarouselFigureDataGrid;//因为添加成功之后，需要刷新这个dataGrid，所以先预定义好
                    var f = parent.$.modalDialog.handler.find('#appCarouselFigureEditForm');
                    f.submit();
                }
            } ]
        });
    }

</script>
<div class="easyui-layout" data-options="fit:true,border:false">
    <div data-options="region:'center',fit:true,border:false">
        <table id="appCarouselFigureDataGrid" data-options="fit:true,border:false"></table>
    </div>
</div>

